<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset='UTF-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Document</title>
    <script type='text/javascript' src='js/vue.js'></script>
</head>

<body>
    <div id='app'>
        <input type="text" v-model='a'>
        <select v-model="value">
            <option value="1">+</option>
            <option value="2">-</option>
            <option value="3">*</option>
            <option value="4">/</option>
        </select>
        <input type="text" v-model='b'>
        <button @click='but'>计算</button>
        <span v-text='result'></span>

    </div>
    <script type='text/javascript'>
        var vm = new Vue({
            el: '#app',
            data: {
                a: '',
                b: '',
                result: '',
                value:''
            },
            methods: {
                but: function () {
                    switch (this.value) {
                        case "1":
                            this.result = parseInt(this.a) + parseInt(this.b);
                            break;
                        case "2":
                            this.result = parseInt(this.a) - parseInt(this.b);
                            break;
                        case "3":
                            this.result = parseInt(this.a) * parseInt(this.b);
                            break;
                        case "4":
                            this.result = parseInt(this.a) / parseInt(this.b);
                            break;
                    }
                }
            },
        });
    </script>
</body>

</html>